package archer.application.elastic.mock.point.entity;

import archer.framework.common.entity.BaseEntity;
import com.avaje.ebean.annotation.DocStore;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import java.math.BigDecimal;

/**
 * @author suzx
 * @date 2016/7/1
 */
@DocStore
@Entity
public class PointDetail extends BaseEntity {

    public static final Find<PointDetail> find = new Find<PointDetail>(PointDetail.class);

    @Column(columnDefinition = "varchar(30) COMMENT '类型'")
    private String type;

    @Column(columnDefinition = "varchar(256) COMMENT '备注'")
    private String remark;

    @Column(columnDefinition = "decimal(24,2) default 0  COMMENT '积分'")
    private BigDecimal point = BigDecimal.ZERO;

    //--------------------------
    //  related table
    //--------------------------
    @ManyToOne
    private UserPoint userPoint;

    public String getType() {
        return type;
    }

    public PointDetail setType(String type) {
        this.type = type;
        return this;
    }

    public String getRemark() {
        return remark;
    }

    public PointDetail setRemark(String remark) {
        this.remark = remark;
        return this;
    }

    public BigDecimal getPoint() {
        return point;
    }

    public PointDetail setPoint(BigDecimal point) {
        this.point = point;
        return this;
    }

    public UserPoint getUserPoint() {
        return userPoint;
    }

    public PointDetail setUserPoint(UserPoint userPoint) {
        this.userPoint = userPoint;
        return this;
    }

    public String getUserPointId() {
        if (this.userPoint == null) {
            this.userPoint = new UserPoint();
        }
        return this.userPoint.getId();
    }

    public PointDetail setUserPointId(String userPointId) {
        if (this.userPoint == null) {
            userPoint = new UserPoint();
        }
        this.userPoint.setId(userPointId);
        return this;
    }

}
